package com.gitee.feizns.quickstart.jackson;

import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.ParseContext;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;

/**
 * 路径
 * @author feizns
 * @since 2025/2/25
 */
public abstract class JPath {

    /**
     * 配置
     */
    public static Configuration config = Configuration.defaultConfiguration()
            .jsonProvider(new JacksonJsonProvider(JsonUtils.objectMapper()))
            .addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL)
            .addOptions(Option.SUPPRESS_EXCEPTIONS);

    /**
     * 使用默认配置
     * @return {@link ParseContext}
     */
    public static ParseContext using() {
        return JsonPath.using(config);
    }

}
